<template>
  <div class="mask" style="display:none">
    <i class="fa fa-close fa-3x close" @click="hide"></i>
    <div class="mation">
      <div class="m_top">
        <div class="tit">详细信息</div>
        <i class="fa fa-close fa-2x" @click="hide"></i>
      </div>
      <div class="center">
        <div class="m_time">
          <span>{{ date }}</span>
          <span>{{ time }}</span>
          <span>{{ week }}</span>
        </div>
        <div class="m_text">
          <span>{{ tits }}</span>
        </div>
      </div>
      <div class="m_footer">
        ID:<span>{{ ids }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "InformationWindow",
  data() {
    return {
      date: "",
      time: "",
      week: "",
      tits: "",
      ids: "",
    };
  },
  methods: {
    setData(r) {
      let timeStr = `${r.year}-${r.mou < 10 ? "0" + r.mou : r.mou}-${
        r.day < 10 ? "0" + r.day : r.day
      }`;
      this.date = timeStr;
      this.time = r.nowTime;
      this.tits = r.title;
      this.week = r.week;
      this.ids = r.id;
    },
    show() {
      let dom = this.$el.querySelector("div");
      this.$el.style.display = "";
      dom.classList.add("setTo");
      setTimeout(() => {
        dom.classList.remove("setTo");
      }, 300);
    },
    hide() {
      let dom = this.$el.querySelector("div");
      dom.classList.add("outTo");
      setTimeout(() => {
        dom.classList.remove("outTo");
        this.$el.style.display = "none";
      }, 200);
    },
    getData(v) {
      this.setData(v);
    },
  },
  mounted() {
    // this.$el.style.display = "none";
    this.$bus.$on("sendData", this.getData);
    this.$bus.$on("showData", this.show);
    
  },
};
</script>

<style lang="scss">
@keyframes MoveTo {
  0% {
    transform: scale(0.2, 0.2);
    opacity: 0;
  }
  60% {
    transform: scale(1.3, 1.3);
    opacity: 0.8;
  }
  100% {
    transform: scale(1, 1);
    opacity: 1;
  }
}
@keyframes outTo {
  0% {
    transform: scale(1, 1);
    opacity: 1;
  }
  20% {
    transform: scale(1.3, 1.3);
    opacity: 0.8;
  }
  100% {
    transform: scale(0, 0);
    opacity: 0;
  }
}
.setTo {
  animation: MoveTo 0.2s 1;
}
.outTo {
  animation: outTo 0.3s;
  // animation-direction:alternate;
}
.mask {
  width: 100%;
  height: 100%;
  position: absolute;
  z-index: 101;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
}
.mask .close {
  position: absolute;
  left: 95%;
  top: 5%;
  cursor: pointer;
}
.mask .close:hover {
  color: #fff;
  transition: 0.3s;
}
.mation {
  width: 600px;
  height: 300px;
  background-color: #fff;
  border-radius: 3px;
  overflow: hidden;
  transition: 0.3s;
  // transform: scale(0.8, 0.8);
  .m_top {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    align-items: center;
    padding-left: 30px;
    padding-right: 10px;
    i {
      transition: 0.3s;
      cursor: pointer;
      &:hover {
        transform: rotate(180deg);
      }
    }
  }
  .center {
    .m_time {
      width: 100%;
      display: flex;
      justify-content: space-between;
      padding: 10px 50px 0px 50px;
      color: #888;
      font-size: 14px;
    }
    .m_text {
      font-weight: bold;
      width: 100%;
      height: 200px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .m_footer {
    color: #999;
    font-size: 12px;
    user-select: none;
  }
}
i{
  color:#000;
}
</style>